# Copyright 2024 The Pigweed Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.

load("@pigweed//pw_unit_test:pw_cc_test.bzl", "pw_cc_test")
load("@rules_cc//cc:cc_library.bzl", "cc_library")

package(
    default_visibility = ["//visibility:public"],
    features = [
        "-layering_check",
        "-ctad_warnings",
    ],
)

cc_library(
    name = "transport",
    srcs = [
        "acl_data_channel.cc",
        "acl_data_packet.cc",
        "command_channel.cc",
        "control_packets.cc",
        "error.cc",
        "iso_data_channel.cc",
        "link_type.cc",
        "sco_data_channel.cc",
        "sco_data_packet.cc",
        "transport.cc",
    ],
    hdrs = [
        "public/pw_bluetooth_sapphire/internal/host/transport/acl_data_channel.h",
        "public/pw_bluetooth_sapphire/internal/host/transport/acl_data_packet.h",
        "public/pw_bluetooth_sapphire/internal/host/transport/command_channel.h",
        "public/pw_bluetooth_sapphire/internal/host/transport/control_packets.h",
        "public/pw_bluetooth_sapphire/internal/host/transport/data_buffer_info.h",
        "public/pw_bluetooth_sapphire/internal/host/transport/emboss_packet.h",
        "public/pw_bluetooth_sapphire/internal/host/transport/error.h",
        "public/pw_bluetooth_sapphire/internal/host/transport/iso_data_channel.h",
        "public/pw_bluetooth_sapphire/internal/host/transport/link_type.h",
        "public/pw_bluetooth_sapphire/internal/host/transport/packet.h",
        "public/pw_bluetooth_sapphire/internal/host/transport/sco_data_channel.h",
        "public/pw_bluetooth_sapphire/internal/host/transport/sco_data_packet.h",
        "public/pw_bluetooth_sapphire/internal/host/transport/slab_allocators.h",
        "public/pw_bluetooth_sapphire/internal/host/transport/transport.h",
    ],
    features = ["-conversion_warnings"],
    strip_include_prefix = "public",
    tags = ["noclangtidy"],
    deps = [
        "//pw_async:dispatcher",
        "//pw_async:task",
        "//pw_bluetooth",
        "//pw_bluetooth:emboss_hci_common",
        "//pw_bluetooth_sapphire:lease",
        "//pw_bluetooth_sapphire/host/common",
        "//pw_bluetooth_sapphire/host/hci-spec",
        "//third_party/fuchsia:fit",
    ],
)

cc_library(
    name = "testing",
    testonly = True,
    srcs = [
        "fake_sco_data_channel.cc",
        "mock_acl_data_channel.cc",
    ],
    hdrs = [
        "public/pw_bluetooth_sapphire/internal/host/transport/fake_acl_connection.h",
        "public/pw_bluetooth_sapphire/internal/host/transport/fake_sco_data_channel.h",
        "public/pw_bluetooth_sapphire/internal/host/transport/mock_acl_data_channel.h",
    ],
    features = ["-conversion_warnings"],
    strip_include_prefix = "public",
    tags = ["noclangtidy"],
    deps = [
        ":transport",
    ],
)

pw_cc_test(
    name = "transport_test",
    srcs = [
        "acl_data_channel_test.cc",
        "command_channel_test.cc",
        "control_packets_test.cc",
        "iso_data_channel_test.cc",
        "packet_test.cc",
        "sco_data_channel_test.cc",
        "sco_data_packet_test.cc",
        "slab_allocators_test.cc",
        "transport_test.cc",
    ],
    features = ["-conversion_warnings"],
    test_main = "//pw_bluetooth_sapphire/host/testing:gtest_main",
    deps = [
        ":testing",
        ":transport",
        "//pw_bluetooth:emboss_hci_test",
        "//pw_bluetooth_sapphire/host/testing",
        "//pw_bluetooth_sapphire/host/testing:mock_controller",
        "//pw_bluetooth_sapphire/host/testing:test_helpers",
    ],
)
